package com.feign.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {

    private T data;
    private Integer code;
    private String msg;

    public static <T> R<T> ok(T data) {
        R<T> r = new R<>();
        r.setData(data);
        r.setCode(200);
        r.setMsg("操作成功!");
        return r;
    }

    public static R<String> error(String msg){
        R<String> r = new R<>();
        r.setCode(500);
        r.setMsg(msg);
        return r;
    }

    public R<T> msg(String msg){
        this.setMsg(msg);
        return this;
    }
}
